/*
 * Copyright (C) 2005-2008 Alfresco Software Limited.
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 51
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 * 
 * As a special exception to the terms and conditions of version 2.0 of the GPL,
 * you may redistribute this Program in connection with Free/Libre and Open
 * Source Software ("FLOSS") applications as described in Alfresco's FLOSS
 * exception. You should have recieved a copy of the text describing the FLOSS
 * exception, and it is also available here:
 * http://www.alfresco.com/legal/licensing"
 */
package org.alfresco.confluence.util;

import java.io.IOException;
import java.io.InputStream;

/**
 * Utility class for managing urls of client side web script services.
 * 
 * @author Yong Qu
 *
 */
public class ServiceUtils {
	/**
	 * Service Base URL
	 */
	public final static String SERVICE_BASE_URL = "/service";
	/**
	 * General Web Script Service
	 */
	public final static String GENERAL_WS_SERVICE_URL = SERVICE_BASE_URL+"/alfresco/ws";
	/**
	 * Repository Information Service
	 */
	public final static String REPO_INFO_SERVICE_URL = SERVICE_BASE_URL+"/alfresco/info";
	/**
	 * Document Service
	 */
	public final static String DOC_SERVICE_URL = SERVICE_BASE_URL+"/alfresco/doc";
	/**
	 * Content Service
	 */
	public final static String CONTENT_SERVICE_URL = SERVICE_BASE_URL+"/alfresco/content";
	/**
	 * Folder Service
	 */
	public final static String FOLDER_SERVICE_URL = SERVICE_BASE_URL+"/alfresco/folder";
	/**
	 * Search Service
	 */
	public final static String SEARCH_SERVICE_URL = SERVICE_BASE_URL+"/alfresco/search";
		
	/**
	 * Read string from the input stream.
	 * 
	 * @param in Input stream
	 * @return String object of the input stream
	 * @throws IOException
	 */
	public static String getContent (InputStream in) throws IOException {
		StringBuffer out = new StringBuffer();
		byte[] b = new byte[4096];
		for (int n; (n = in.read(b)) != -1;) {
			out.append(new String(b, 0, n));
		}
		return out.toString();
	}
		
}
